 
import type { AxiosProgressEvent, GenericAbortSignal } from 'axios'
import request from '@/utils/request'

export function fetchChatAPI<_T = any>(
  prompt: string,
  options?: { conversationId?: string; parentMessageId?: string },
  signal?: GenericAbortSignal
) {
  return request.post('/chat', { data: { prompt, options }, signal })
}

export function fetchChatConfig<_T = any>() {
  return request.get('/config')
}

export async function fetchChatAPIProcess<_T = any>(params: {
  prompt: string
  options?: { conversationId?: string; parentMessageId?: string }
  signal?: GenericAbortSignal
  onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
}) {
  return await fetch('/chat', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      // model: 'deepseek-r1:8b',
      prompt: params.prompt,
      stream: true,
      session_id: params.options?.conversationId,
    }),
  })
}

export function fetchSession<_T>() {
  return request.get('/session')
}

export function fetchVerify<_T>(token: string) {
  return request.post('/verify', { data: { token } })
}
